import defaultSettings from '@/settings'

const { showSettings, fixedHeader, sidebarLogo } = defaultSettings
// 知识点:对象.不存在的属性值为undefined
// undefined-未定义 null值(是一个具体的值你得赋予他null 他才能是null空值)
const state = {
  showSettings: showSettings, // 全局关键信息配置
  fixedHeader: fixedHeader, // 是否固定头部
  sidebarLogo: sidebarLogo // 控制左侧导航的logo
}

const mutations = {
  CHANGE_SETTING: (state, { key, value }) => { // 修改全局关键信息配置的值
    // eslint-disable-next-line no-prototype-builtins
    if (state.hasOwnProperty(key)) {
      state[key] = value
    }
  }
}

const actions = {
  changeSetting({ commit }, data) {
    commit('CHANGE_SETTING', data)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

